#include<iostream>
using namespace std;
const int N = 1e3 + 10;
int n;
char arr[N][N];
bool col[N], dg[N], ndg[N];	
void dfs(int u)
{
	if (u == n ) {
		for (int i = 0; i < n; i++) {
			puts(arr[i]);
			cout << endl;
		}
		cout << "--------------------------------" << endl;
	}
	for (int i = 0; i < n; i++) {
		if (!col[i] && !dg[u+i] && !ndg[n-u+i]) {
			arr[u][i] = 'Q';
			col[i] = dg[i + u] = ndg[n - u + i] = 1;
			dfs(u + 1);
			col[i] = dg[i + u] = ndg[n - u + i] = 0;
			arr[u][i] = '.';
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			arr[i][j] = '.';
		}
	}
	dfs(0);
	return 0;
}